<!DOCTYPE html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/extras/chrome/cc/picture.html">
<link rel="import" href="/tracing/ui/analysis/generic_object_view.html">
<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html">
<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_debugger.html">

<script>
'use strict';

tr.exportTo('tr.ui.e.chrome.cc', function() {
  /*
   * Displays a picture snapshot in a human readable form.
   * @constructor
   */
  const PictureSnapshotView = tr.ui.b.define(
      'tr-ui-e-chrome-cc-picture-snapshot-view',
      tr.ui.analysis.ObjectSnapshotView);

  PictureSnapshotView.prototype = {
    __proto__: tr.ui.analysis.ObjectSnapshotView.prototype,

    decorate() {
      Polymer.dom(this).classList.add(
          'tr-ui-e-chrome-cc-picture-snapshot-view');
      this.style.display = 'flex';
      this.style.flexGrow = 1;
      this.style.flexShrink = 1;
      this.style.flexBasis = 'auto';
      this.style.minWidth = 0;
      this.pictureDebugger_ = new tr.ui.e.chrome.cc.PictureDebugger();
      this.pictureDebugger_.style.flexGrow = 1;
      this.pictureDebugger_.style.flexShrink = 1;
      this.pictureDebugger_.style.flexBasis = 'auto';
      this.pictureDebugger_.style.minWidth = 0;
      Polymer.dom(this).appendChild(this.pictureDebugger_);
    },

    updateContents() {
      if (this.objectSnapshot_ && this.pictureDebugger_) {
        this.pictureDebugger_.picture = this.objectSnapshot_;
      }
    }
  };

  tr.ui.analysis.ObjectSnapshotView.register(
      PictureSnapshotView,
      {
        typeNames: ['cc::Picture', 'cc::LayeredPicture'],
        showInstances: false
      });

  return {
    PictureSnapshotView,
  };
});
</script>
